package com.ticket.sass.admin.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ticket.sass.admin.dto.input.order.RefundRecordInput;
import com.ticket.sass.admin.mapper.LaterPayRefundRecordMapper;
import com.ticket.sass.admin.service.BaseService;
import com.ticket.sass.common.entity.tenant.LaterPayRefundRecordEntity;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ywb
 * @since 2024-05-07
 */
@Service
public class LaterPayRefundRecordServiceImpl extends ServiceImpl<LaterPayRefundRecordMapper, LaterPayRefundRecordEntity> implements BaseService<LaterPayRefundRecordEntity> {
    public IPage<LaterPayRefundRecordEntity> iPage(RefundRecordInput input) {
        // 创建 Page 对象
        Page<LaterPayRefundRecordEntity> page = new Page<>(input.getPageNum(), input.getPageSize());
        
        // 创建 QueryWrapper 对象
        QueryWrapper<LaterPayRefundRecordEntity> queryWrapper = new QueryWrapper<>();
        
        queryWrapper.like(StrUtil.isNotEmpty(input.getVerifyCode()), "verify_code", input.getVerifyCode());
        
        queryWrapper.in(input.getUserIds().size() > 0, "user_id", input.getUserIds());
        queryWrapper.orderByDesc("id");
        
        return page(page, queryWrapper);
    }
}
